package resources;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

import localization.LocalizationManager;

public class GraphicManager {
	
	private final static String GRAPHIC_FILE = "/graphics.png";	
	private static GraphicManager instance;
		
	private GraphicManager(){
		readGraphicFile();
	}

	public static GraphicManager getInstance() {
		if( instance == null ){
			instance = new GraphicManager();
		}		
		return instance;
	}
	
	private Image graphicImage;
	
	private void readGraphicFile(){
		try{
        	graphicImage = Image.createImage( GRAPHIC_FILE );
        }catch( java.io.IOException e){ 
        	throw new RuntimeException( LocalizationManager.getCurrentLanguageFromInstance().getGraphicLoadFailedText() );
        }	
	}
	
	public Rectangle getCommentSignCoordinates(){
		return new Rectangle( 0, 0, 3, 9);
	}
	
	public Image getCommentSign(){
		Image result = Image.createImage(getCommentSignCoordinates().getWidth(), getCommentSignCoordinates().getHeight());		
		
		Graphics g = result.getGraphics();
		g.drawImage(graphicImage, 0, 0, Graphics.TOP | Graphics.LEFT );		
		
		return result;
	}

}
